package com.syq.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.syq.mapper.DtsAccountTraceMapper;
import com.syq.pojo.DtsAccountTrace;
import com.syq.service.DtsAccountTraceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;

/**
 * @ClassName: DtsAccountTraceServiceImpl
 * @Description: TODO
 * @Create by: syq
 * @Date: 2022/7/25 21:28
 */

@Service
@Transactional
public class DtsAccountTraceServiceImpl implements DtsAccountTraceService {

    @Autowired
    private DtsAccountTraceMapper dtsAccountTraceMapper;
    @Override
    public IPage<DtsAccountTrace> findByPage(Integer page, Integer limit, String username, Integer[] statusArray, String mobile, String sort, String order) {
        return dtsAccountTraceMapper.selectPage(new Page<DtsAccountTrace>(page,limit),
                new QueryWrapper<DtsAccountTrace>()
                        .like(!StringUtils.isEmpty(username),"username",username)
                        .eq(!StringUtils.isEmpty(mobile),"mobile",mobile)
                        .in(!StringUtils.isEmpty(statusArray),"status",statusArray)
                        .orderBy(!StringUtils.isEmpty(sort),order.equalsIgnoreCase("Asc"),sort));
    }

    @Override
    public void updateStatus(Integer id, Integer status) {
        dtsAccountTraceMapper.updateStatus(id,status);
    }
}
